var workFlowInfo_tr_temp = '<tr>'
								+'<td class="text-right col-sm-2" style="background-color:#e8e8e8"><strong>当前处理人:</strong></td>'
								+'<td class="col-sm-8"><span>${extUser}</span></td>'
							+'</tr>'
					        +'<tr>'
					        	+'<td class="text-right col-sm-2" style="background-color:#e8e8e8"><strong>当前节点:</strong></td>'
					        	+'<td class="col-sm-8"><span>${nodeDefName}</span></td>'
					        +'</tr>'
					        +'<tr>'
					        	+'<td class="text-right col-sm-2" style="background-color:#e8e8e8"><strong>下一个节点:</strong></td>'
					        	+'<td class="col-sm-8"><span>${outcomeNodes}</span></td>'
  	                        +'</tr>'
  	                        +'<tr>'
  	                        	+'<td class="text-right col-sm-2" style="background-color:#e8e8e8"><strong>已处理:</strong></td>'
  	                        	+'<td class="col-sm-8"><span></span></td>'
  		                    +'</tr>';

//初始化流程信息
$(function(){
	//使用ajax获取流程信息
	//获取表单KEY
	var formName = $("#form_identity_").val();
	//获取流程定义
	var flowKey = $("#flowKey_").val();
	//是否启动流程
	var isStart = true;
	if($("#isStart").val() && $("#isStart").val() != ""){
		isStart = $("#isStart").val();
	}
	if($("form").length == 1) {
		$("form")[0].onsubmit = validateForm;
	}
	//业务主键
	var businessId = $("#businessId").val();
	$.ajax({
	    type: 'POST',
	    async:false,
	    url:PATH+"/bpm/workflow/getWorkFlowInfoByEdit" ,
	    data: {formName:formName,flowKey:flowKey,isStart:isStart,businessId:businessId},
	    dataType: "json",
	    success: initWorkFlow,
	    error:error,
	});
});
function initWorkFlow(data){
	//是否启动流程
	if(data.bpm_flow_excute_type == "bpm_flow_start_"){
		initStartInfo(data);
	}else{
		initApproveInfo(data);
	}
}

function initStartInfo(data){
	//初始化流程实例ID
	if(data.proInsId){
		$(".proInsId").val(data.proInsId);	
	}

	//初始化流程执行信息
	var bpm_flow_excute_type = data.bpm_flow_excute_type;
	if(bpm_flow_excute_type){
		$("#bpm_flow_excute_type").val(bpm_flow_excute_type);
	}
	$("#flowOpinions").attr("src",PATH+"/bpm/workflow/opinions?proInstID="); 
	initWorkFlowInfo(data);
	$(".workflow-opt-task-tr").css("display","none");
	var isopt = data.isopt;
	if(isopt){
		$("#is_work_flow_").val(true);
		if($(".att-show").find("input[name='soureBillID']")[0]){
			$($(".att-show").find("input[name='soureBillID']")[0]).val(data.proInsId);
		}
		initEditNodeInfo(data);
	}else{
		$(".att-show").css("display","none");
	}
	//初始化岗位信息
	if(data.userPosts){
		var userPosts = data.userPosts;
		userPosts = jQuery.parseJSON(userPosts);
		$(userPosts).each(function(){ 
			$("#postId").append("<option value='"+this.postId+"'>"+this.postName+"</option>");
		}); 
	}
	//加载流程图
	var diagram_url = PATH+"/bpm/workflow/queryFlowImage?";
	if(data.defId){
		diagram_url += "defId="+data.defId;
	}
	$("#diagram_iframe").attr("src",diagram_url); 
}

